package cn.itcast.syntax

/**
  * @Package cn.itcast.syntax
  * @author KTL
  * @date 2021/5/14 0014 17:15
  * @version V1.0
  * @Copyright © 2015-04-29  One for each, and two for each
  *    演示scala数据类型-值类型
  */
object Demo2_DataType {
  def main(args: Array[String]): Unit = {
    //注意：scala的值类型都是大写字母开头
    val v1:Byte=1
    val v2:Short=1
    val v3:Int=1
    val v4:Long=1L
    val v5:Double=1
    val v6:Float=1
    val v7:Boolean=true
    val v8:Char='c'

    //注意1：String定义方式""
    val name:String ="jack"

    //注意2：String定义方式 """ """
    val names:String=
      """
        |my name is jack?
        |what's your name
        |how are you ?
      """.stripMargin
  }
  //注意3:String字符串拼接可以使用插值表达式
  val tableName="stduent"
  val id = 1
  //之前写法
  val sql1:String="select * from "+tableName+"where id = "+id
  //现在的使用插值表达式
  val sql2:String=s"select * from ${tableName} where id ${id}"
  //三引号插值表达式
  val sql3:String=
    s"""
      |select *
      |from ${tableName}
      |where id=${id}
    """.stripMargin
  println(sql3)
}

